home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Examples / Draw / Include / DrawPart.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  11.2 KB  |  355 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawPart.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef DRAWPART_H
  13. #define DRAWPART_H
  14.  
  15. // ----- Part Layer -----
  16.  
  17. #ifndef FWPARTNG_H
  18. #include "FWPartng.h"
  19. #endif
  20.  
  21. #ifndef FWSELECT_H
  22. #include "FWSelect.h"
  23. #endif
  24.  
  25. // ----- OS Layer -----
  26.  
  27. #ifndef FWCOLOR_H
  28. #include "FWColor.h"
  29. #endif
  30.  
  31. #ifndef FWBWPAT_H
  32. #include "FWBWPat.h"
  33. #endif
  34.  
  35. #ifndef FWPOINT_H
  36. #include "FWPoint.h"
  37. #endif
  38.  
  39. #ifndef FWRESFIL_H
  40. #include "FWResFil.h"
  41. #endif
  42.  
  43. //========================================================================================
  44. //    Forward Declarations
  45. //========================================================================================
  46.  
  47. #if FW_LIB_EXPORT_PRAGMAS
  48. #pragma import on
  49. #endif
  50.  
  51. class FW_CLASS_ATTR FW_CFloatingWindow;
  52. class FW_CLASS_ATTR FW_CMenuEvent;
  53. class FW_CLASS_ATTR FW_CDropCommand;
  54. class FW_CLASS_ATTR FW_CPresentation;
  55.  
  56. #if FW_LIB_EXPORT_PRAGMAS
  57. #pragma import off
  58. #endif
  59.  
  60. class FW_CLASS_ATTR CBaseShape;
  61. class FW_CLASS_ATTR CProxyShape;
  62. class FW_CLASS_ATTR CToolFrame;
  63. class FW_CLASS_ATTR CPaletteFrame;
  64. class FW_CLASS_ATTR CPatternFrame;
  65. class FW_CLASS_ATTR CDrawSelection;
  66. class FW_CLASS_ATTR FW_CGraphicContext;
  67. class FW_CLASS_ATTR CDrawLinkManager;
  68.  
  69. //========================================================================================
  70. //    Defines
  71. //========================================================================================
  72.  
  73. #define kContentAnnotationProp        "Apple:Framework:Proposition:ContentAnnotation"
  74. #define kContentAnnotationValue        "Apple:Framework:Value:ContentAnnotation"
  75.  
  76. //========================================================================================
  77. //    class CDrawPart
  78. //========================================================================================
  79.  
  80. class FW_CLASS_ATTR CDrawPart : public FW_CEmbeddingPart
  81. {
  82. public:
  83.     static const ODValueType kPartKind;
  84.     static const ODValueType kPartUserName;
  85.  
  86.     friend class CDrawLinkManager;
  87.  
  88. //----------------------------------------------------------------------------------------
  89. //    Initialization/Destruction
  90. //
  91. public:        
  92.     CDrawPart(ODPart* odPart);
  93.     virtual ~ CDrawPart();
  94.  
  95.     virtual void            Initialize(Environment *ev);    
  96.     void                    InitializeMenuBar(Environment* ev, FW_CMenuBar* menuBar);
  97.     
  98. //----------------------------------------------------------------------------------------
  99. //    Inherited API
  100. //
  101. public:
  102.     virtual FW_CFrame*         NewFrame(Environment *ev,
  103.                                 ODFrame* odFrame, 
  104.                                 FW_CPresentation* presentation,
  105.                                 FW_Boolean fromStorage);
  106.                                     
  107.     virtual void             ExternalizeContent(Environment *ev, 
  108.                                 ODStorageUnit* storageUnit, 
  109.                                 FW_CCloneInfo* cloneInfo);
  110.     virtual void             InternalizeContent(Environment *ev, 
  111.                                 ODStorageUnit* storageUnit, 
  112.                                 FW_CCloneInfo* cloneInfo);
  113.  
  114.     virtual FW_Boolean        DoMenu(Environment *ev, const FW_CMenuEvent& theMenuEvent);
  115.     virtual FW_Boolean        DoAdjustMenus(Environment *ev, FW_CMenuBar* menuBar, 
  116.                                         FW_Boolean hasMenuFocus, FW_Boolean isRoot);
  117.     
  118.     virtual FW_CLinkManager*     NewLinkManager(Environment *ev);
  119.     
  120. //----------------------------------------------------------------------------------------
  121. //    New API
  122. //
  123. public:    
  124.     void                    RemoveShape(Environment* ev, CBaseShape* shape);
  125.     void                    AddShape(Environment* ev, CBaseShape* shape);
  126.     void                    DeleteShape(Environment* ev, CBaseShape* shape);
  127.     void                    AddShapeAfter(Environment* ev, CBaseShape* after, CBaseShape* shape);
  128.  
  129.     CBaseShape*             WhichShape(Environment *ev, 
  130.                                         FW_CGraphicContext& gc,
  131.                                         const FW_CMouseEvent& theMouseEvent,
  132.                                         FW_Boolean hasToBeSelected) const;
  133.  
  134.     FW_CPrivOrderedCollection*        GetShapeList() const;
  135.     FW_CFixed                GetPenSize() const;
  136.     unsigned short            GetRenderVerb() const;
  137.  
  138.     FW_CPoint                GetDrawingSize() const;
  139.  
  140.     void                    CheckTool(Environment* ev, unsigned short oldTool, unsigned short newTool);
  141.     void                    CheckRenderVerb(Environment* ev, unsigned short oldRenderVerb, unsigned short newRenderVerb);
  142.     void                    SetRenderVerb(Environment* ev, unsigned short renderVerb);
  143.     
  144.     void                    GetFillColor(FW_CColor& color) const;
  145.     void                    GetFrameColor(FW_CColor& color) const;
  146.  
  147.     void                    SetFillColor(Environment* ev, const FW_CColor& color);
  148.     void                    SetFrameColor(Environment* ev, const FW_CColor& color);
  149.     
  150.     FW_PPattern                GetFillPattern() const;
  151.     FW_PPattern                GetFramePattern() const;
  152.  
  153.     void                    SetFillPattern(Environment* ev, short newFillPatIndex);
  154.     void                    SetFramePattern(Environment* ev, short newFramePatIndex);
  155.     
  156.     void                    MoveForward(Environment *ev);
  157.     void                    MoveBackward(Environment *ev);
  158.     void                    MoveToFront(Environment *ev);
  159.     void                    MoveToBack(Environment *ev);
  160.     void                    UpdateAfterMove(Environment* ev);
  161.  
  162.     void                    SetTool(Environment* ev, unsigned short newTool);
  163.     unsigned short            GetTool() const;
  164.                                 
  165.     FW_PPattern                GetPattern(short patIndex) const;
  166.     
  167.     void                     UpdateAllToolFacets(Environment *ev);
  168.  
  169.     FW_CPresentation*        GetMainPresentation() const;
  170.     FW_CPresentation*        GetPalettePresentation() const;
  171.     FW_CPresentation*        GetPatternPresentation() const;
  172.     FW_CPresentation*        GetToolPresentation() const;
  173.  
  174.     FW_Boolean                IsAutoGridOn() const;
  175.     
  176.     CBaseShape*                NewShape(Environment* ev, unsigned short shapeType);
  177.  
  178.     //--- Persistent link support ---
  179.     void                    DoPostCreate(Environment* ev);    // MacApp forever!
  180.     CBaseShape*                FindShapeWithIndex(short extIndex);
  181.  
  182. private:
  183.     FW_CPrivOrderedCollection*        ExtractSelection(Environment* ev);
  184.     
  185.  
  186. //----------------------------------------------------------------------------------------
  187. //    Data Members
  188. //
  189. private:    
  190.     short                fNbEmbedded;
  191.         
  192.     FW_CFloatingWindow*    fPaletteWindow;
  193.     FW_CFloatingWindow*    fPatternWindow;
  194.     FW_CFloatingWindow*    fToolsWindow;
  195.  
  196.     CToolFrame*            fToolFrame;
  197.     CPaletteFrame*        fPaletteFrame;
  198.     CPatternFrame*        fPatternFrame;
  199.         
  200.     FW_CPrivOrderedCollection*    fShapeList;
  201.     FW_CPoint            fDrawingSize;
  202.     
  203.     unsigned short        fTool;
  204.     FW_CFixed            fCurrentPenSize;
  205.     unsigned short        fRenderVerb;
  206.     FW_CColor            fFillColor;
  207.     FW_CColor            fFrameColor;
  208.     short                fFillPatIndex;
  209.     short                fFramePatIndex;
  210.     
  211.     CDrawSelection*        fDrawSelection;    // Attention I don't own the selection the presentation is
  212.     
  213.     FW_CPresentation*    fPalettePresentation;
  214.     FW_CPresentation*    fPatternPresentation;
  215.     FW_CPresentation*    fToolPresentation;
  216.     FW_CPresentation*    fMainPresentation;
  217.     FW_CPresentation*    fAlignObjectsPresentation;
  218.     
  219.     FW_PPattern            fPatternTable[12];
  220.     
  221.     FW_Boolean            fAutoGrid;
  222.  
  223.     ODCommandID            fUnit;
  224.     ODCommandID            fArcUnit;
  225.  
  226.     FW_Boolean            fPostCreated;    // perform DoPostCreate only once
  227. };
  228.  
  229. //========================================================================================
  230. //    Inlines
  231. //========================================================================================
  232.  
  233. //----------------------------------------------------------------------------------------
  234. //    CDrawPart::GetDrawingSize
  235. //----------------------------------------------------------------------------------------
  236. inline FW_CPoint CDrawPart::GetDrawingSize() const
  237. {
  238.     return fDrawingSize;
  239. }
  240.  
  241. //----------------------------------------------------------------------------------------
  242. //    CDrawPart::IsAutoGridOn
  243. //----------------------------------------------------------------------------------------
  244. inline FW_Boolean CDrawPart::IsAutoGridOn() const
  245. {
  246.     return fAutoGrid;
  247. }
  248.  
  249. //----------------------------------------------------------------------------------------
  250. //    CDrawPart::GetShapeList
  251. //----------------------------------------------------------------------------------------
  252. inline FW_CPrivOrderedCollection* CDrawPart::GetShapeList() const
  253. {
  254.     return fShapeList;
  255. }
  256.  
  257. //----------------------------------------------------------------------------------------
  258. //    CDrawPart::GetPenSize
  259. //----------------------------------------------------------------------------------------
  260. inline FW_CFixed CDrawPart::GetPenSize() const
  261. {
  262.     return fCurrentPenSize;
  263. }
  264.  
  265. //----------------------------------------------------------------------------------------
  266. //    CDrawPart::GetRenderVerb
  267. //----------------------------------------------------------------------------------------
  268. inline unsigned short CDrawPart::GetRenderVerb() const
  269. {
  270.     return fRenderVerb;
  271. }
  272.  
  273. //----------------------------------------------------------------------------------------
  274. //    CDrawPart::GetTool
  275. //----------------------------------------------------------------------------------------
  276. inline unsigned short CDrawPart::GetTool() const
  277. {
  278.     return fTool;
  279. }
  280.  
  281. //----------------------------------------------------------------------------------------
  282. //    CDrawPart::GetMainPresentation
  283. //----------------------------------------------------------------------------------------
  284. inline FW_CPresentation* CDrawPart::GetMainPresentation() const
  285. {
  286.     return fMainPresentation;
  287. }
  288.  
  289. //----------------------------------------------------------------------------------------
  290. //    CDrawPart::GetPalettePresentation
  291. //----------------------------------------------------------------------------------------
  292. inline FW_CPresentation* CDrawPart::GetPalettePresentation() const
  293. {
  294.     return fPalettePresentation;
  295. }
  296.  
  297. //----------------------------------------------------------------------------------------
  298. //    CDrawPart::GetPatternPresentation
  299. //----------------------------------------------------------------------------------------
  300. inline FW_CPresentation* CDrawPart::GetPatternPresentation() const
  301. {
  302.     return fPatternPresentation;
  303. }
  304.  
  305. //----------------------------------------------------------------------------------------
  306. //    CDrawPart::GetToolPresentation
  307. //----------------------------------------------------------------------------------------
  308. inline FW_CPresentation* CDrawPart::GetToolPresentation() const
  309. {
  310.     return fToolPresentation;
  311. }
  312.  
  313. //----------------------------------------------------------------------------------------
  314. //    CDrawPart::GetPattern
  315. //----------------------------------------------------------------------------------------
  316. inline FW_PPattern CDrawPart::GetPattern(short patIndex) const
  317. {
  318.     FW_ASSERT(patIndex>=0 && patIndex<12);
  319.     return fPatternTable[patIndex];
  320. }
  321.  
  322. //----------------------------------------------------------------------------------------
  323. //    CDrawPart::GetFillColor
  324. //----------------------------------------------------------------------------------------
  325. inline void CDrawPart::GetFillColor(FW_CColor& color) const
  326. {
  327.     color = fFillColor;
  328. }
  329.  
  330. //----------------------------------------------------------------------------------------
  331. //    CDrawPart::GetFrameColor
  332. //----------------------------------------------------------------------------------------
  333. inline void CDrawPart::GetFrameColor(FW_CColor& color) const
  334. {
  335.     color = fFrameColor;
  336. }
  337.  
  338. //----------------------------------------------------------------------------------------
  339. //    CDrawPart::GetFillPattern
  340. //----------------------------------------------------------------------------------------
  341. inline FW_PPattern CDrawPart::GetFillPattern() const
  342. {
  343.     return fPatternTable[fFillPatIndex];
  344. }
  345.  
  346. //----------------------------------------------------------------------------------------
  347. //    CDrawPart::GetFramePattern
  348. //----------------------------------------------------------------------------------------
  349. inline FW_PPattern CDrawPart::GetFramePattern() const
  350. {
  351.     return fPatternTable[fFramePatIndex];
  352. }
  353.  
  354. #endif
  355.